package com.migu.spms.webapi.data;

import java.util.Date;
import java.util.List;

import com.migu.spms.dao.entity.RequireAttachmentCriteria;
import com.migu.spms.utils.annotation.type.Column;

import lombok.Data;

/**
 * 
 * 项目名称: SPMS需求管理 包: com.migu.spms.webapi.data 类名称: CreateRequireRequest.java
 * 类描述: 创建需求请求包装类 创建人: fw 创建时间: 2017年6月13日 下午4:27:21
 */
@Data
public class EditRequireRequest {
	private Long id;
	// 项目id
	@Column(name = "项目id", isNull = "N")
	private Long projectId;
	// 需求名称
	@Column(name = "需求名称", isNull = "N")
	private String requireName;
	// 需求类别id
	@Column(name = "需求类别id", isNull = "Y")
	private Long requireTypeId;
	// 需求类别名称
	@Column(name = "需求类别名称", isNull = "Y")
	private String requireTypeName;
	// 期望完成时间
	@Column(name = "期望完成时间", isNull = "Y")
	private Date expectFinishTime;
	// 期望开始时间
	@Column(name = "期望开始时间", isNull = "Y")
	private Date expectStartTime;
	// 优先级
	@Column(name = "优先级", isNull = "Y")
	private String priorityRank;
	@Column(name = "关联业务需求名称", isNull = "Y")
	private String relativeBusinessRequireName;
	@Column(name = "关联业务需求id", isNull = "Y")
	private String relativeBusinessRequireId;
	// 基线版本
	@Column(name = "基线版本", isNull = "Y")
	private String baselineVersion;
	// 预估工作量
	@Column(name = "预估工作量", isNull = "Y")
	private String estimateWorkload;
	// 父需求id
	@Column(name = "父需求id", isNull = "Y", introduction = "主键id，不是业务需求id")
	private Long parentId;
	// 创建人id
	private Long creatorId;
	// 创建人姓名
	private String creatorName;
	// 评论
	@Column(name = "评论", isNull = "Y")
	private String comment;
	// 需求详情
	@Column(name = "需求详情", isNull = "N")
	private String details;
	@Column(name = "附件", isNull = "Y", introduction = "格式为列表")
	private List<RequireAttachmentCriteria> attachments;
	@Column(name = "测试人员", isNull = "Y", introduction = "格式为列表")
	private List<User> testers;
	@Column(name = "开发人员", isNull = "Y", introduction = "格式为列表")
	private List<User> developers;
	@Column(name = "开发负责人id", isNull = "Y")
	private Long developResponsibleId;
	@Column(name = "开发负责人姓名", isNull = "Y")
	private String developResponsibleName;
	@Column(name = "测试负责人id", isNull = "Y")
	private Long testResponsibleId;
	@Column(name = "测试负责人姓名", isNull = "Y")
	private String testResponsibleName;
	@Column(name = "项目编码", isNull = "Y")
	private String projectNumber;
	@Column(name = "计划上线版本", isNull = "Y")
	private String planOnlineVersion;
	// 仅用于批量更新需求时
	@Column(name = "需求主键id集合", isNull = "Y")
	private List<Long> ids;

	private String operator;

	@Column(name = "预估测试工作量", isNull = "Y")
	private String estimateTestWorkload;
	@Column(name = "测试计划完成时间", isNull = "Y")
	private Date expectTestFinishTime;
	@Column(name = "测试计划开始时间", isNull = "Y")
	private Date expectTestStartTime;

	//清空时间，后台没法接收null，要求前端传0，现在处理回来
	public int[] initTime() {
		int[] changeList = {0,0,0,0};
		if (this.expectFinishTime!=null && this.expectFinishTime.getTime() == 0) {
			this.expectFinishTime = null;
			changeList[0] = 1;
		}
		if (this.expectStartTime!=null && this.expectStartTime.getTime() == 0) {
			this.expectStartTime = null;
			changeList[1] = 1;
		}
		if (this.expectTestFinishTime!=null && this.expectTestFinishTime.getTime() == 0) {
			this.expectTestFinishTime = null;
			changeList[2] = 1;
		}
		if (this.expectTestStartTime!=null && this.expectTestStartTime.getTime() == 0) {
			this.expectTestStartTime = null;
			changeList[3] = 1;
		}
		return changeList;
	}
	
	public void resetTime(int[] changeList){
		Date date0 = new Date();
		date0.setTime(0);
		if(changeList[0]==1){
			this.expectFinishTime = date0;
		}
		if(changeList[1]==1){
			this.expectStartTime = date0;
		}
		if(changeList[2]==1){
			this.expectTestFinishTime = date0;
		}
		if(changeList[3]==1){
			this.expectTestStartTime = date0;
		}
	}
	
}
